package com.wzw.expression.record.expression;

import com.wzw.expression.expression.operation.AnnotationOperationProvider;
import com.wzw.expression.expression.operation.Operation;
import com.wzw.expression.record.annotations.IRecord;

import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.util.Collection;
import java.util.Collections;

/**
 * @author Wangzhiwen
 */
public class IRecordAnnotationOperationProvider implements AnnotationOperationProvider {

    @Override
    public Class<? extends Annotation> getType() {
        return IRecord.class;
    }

    @Override
    public Collection<Operation> get(Annotation annotation, AnnotatedElement ae) {
        IRecord iRecord = (IRecord) annotation;
        IRecordOperation operation = IRecordOperation.annotationToThis(iRecord, ae.toString());
        return Collections.singletonList(operation);
    }
}
